Print one to nine


Posted by Christy on 2022-04-19

Description: Print one to nine with for loop, while loop and do…while loop

// The input would be below:

1
2
3
4
5
6
7
8
9
// for loop

for (let i = 1; i <= 9; i++) {
  console.log(i);
}
// while loop

let i = 1;
while (i <= 9) {
  console.log(i);
  i++;
}
// do...while loop

let i = 1;
do {
  console.log(i);
  i++;
} while (i <= 9);









Related Posts

超過 200 美金的教訓…三週托福 96→104 血淚經驗談(無補習、口說寫作未用模板)

超過 200 美金的教訓…三週托福 96→104 血淚經驗談(無補習、口說寫作未用模板)

早起跑來跑去卻停滯進度的一天

早起跑來跑去卻停滯進度的一天

[20] 強制轉型 - 轉換值、ToString、JSON

[20] 強制轉型 - 轉換值、ToString、JSON


Comments